--
-- IP鉴权.
--


local cloak = require("src.cloak")

local fmt = string.format

--- 检查IP
--
local function access()
  local remote_addr = ngx.var.remote_addr
  ngx.log(ngx.DEBUG, fmt("Req ip= %s", remote_addr))

  if cloak.ip_in_cidrs(remote_addr) then
    ngx.ctx.is_filter_ip = true
  else
    ngx.ctx.is_filter_ip = false
  end
end

return {
  access = access
}